# -*- coding: utf-8 -*-

"""The application's Globals object"""

from pylons import config

class Globals(object):
    """Globals acts as a container for objects available throughout the
    life of the application
    """

    def __init__(self):
        """One instance of Globals is created during application
        initialization and is available during requests via the 'g'
        variable
        """
        from onlinebrary.lib.processor import Processor
        self.processor = Processor()

        from onlinebrary.lib.converter.feed2fb2 import FeedToFb2Converter
        from onlinebrary.lib.converter.html2pdf import HtmlToPdfConverter
        self.feed_to_fb2 = FeedToFb2Converter()
        self.html_to_pdf = HtmlToPdfConverter()

        from onlinebrary.lib.viewer import Viewer
        self.viewer = Viewer()

        from onlinebrary.lib.aggregator.lib_ru import LibRuAggregator
        from onlinebrary.lib.aggregator.new_fictionbook_ru import NewFictionbookRuAggregator
        from onlinebrary.lib.aggregator.aldebaran_ru import AldebaranRuAggregator
        self.aggregators_pool = [
                LibRuAggregator(),
                NewFictionbookRuAggregator(),
                AldebaranRuAggregator()
                ]
        
        self.default_error_msg = "К сожалению, произошла ошибка :("
        
        import time
        import md5
        import random
        self.random_id = lambda : md5.new(str(time.time()) + str(random.random())).hexdigest()
        
        
        
        
        
        
        
